# 面向对象特点：继承、多态、封装
class Player(object):
    numbers = 0  # 类属性 （不属于单个实例）
    levels = ['青铜', '白银', '黄金', '钻石', '王者']

    def __init__(self, name, age, city, level):  # 初始化函数（构造函数
        self.name = name
        self.age = age
        self.city = city
        self.level = level
        Player.numbers += 1  # 统计玩家人数
        if level not in Player.levels:
            raise Exception("段位设置错误！")

    def level_up(self):
        i = Player.levels.index(self.level)
        if i < len(Player.levels) - 1:
            self.level = Player.levels[i + 1]
            print("已升级，当前等级为", self.level)
        else:
            print("您的等级已是最高级,无法升级")

    def show(self):  # 实例的方法
        print('我是王者游戏的第%d个玩家，我的名字是%s,我来自%s' % (Player.numbers, self.name, self.city))

    def get_weapon(self, weapon):
        self.weapon = weapon

    def show_weapon(self):
        return self.weapon.show_weapon()

    # 类方法
    @classmethod
    def get_players(cls):  # 类方法
        print("玩家数量到达了%d人" % cls.numbers)

    @staticmethod
    def isValid(**kwargs):
        if kwargs['age'] > 18:
            return True
        else:
            return False


# 继承Player
class VIP(Player):
    def __init__(self,name, age, city, level,money):
        super().__init__(name, age, city, level)
        self.money = money

    # 实例方法重写
    def show(self):  # 实例的方法
        print('我是王者游戏的第%d个玩家，我的名字是%s,我来自%s,充值了%d块钱' % (Player.numbers, self.name, self.city, self.money))


# lily = VIP('lily',21,'上海','钻石')
# print(type(lily))  # <class '__main__.VIP'>
# print(isinstance(lily,Player)) # True
# print(isinstance(lily,VIP)) # True

v = VIP('jack',21,'上海','钻石',100)
v.show()